import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { visualizer } from "rollup-plugin-visualizer";
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    visualizer({
      open: true, // 自动打开浏览器
      gzipSize: true, // 显示 gzip 体积
      brotliSize: true, // 显示 brotli 体积
      filename: "stats.html",
    }),
  ],
  server: {
    port: 8080,
    host: true, // 监听所有地址
    open: true,
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  build: {
    assetsInlineLimit: 10240, // 将小于 4KB 的资源转为 base64
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles/common/var.scss" as *;
        @use "@/styles/common/mixin.scss" as *;`,
      },
    },
  },
});
